package cate.game.role.pvp.teampvp.msg;

import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTeamPvp;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

@ClientMsg(title = "组队竞技邀请好友的请求")
public class TeamPvpInviteFriendReq implements MsgInput {
    @NoteField("邀请的好友uid")
    public String inviteUid;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        if (StringUtils.isBlank(inviteUid)) {
            game.notice.message(cc.getRole(), "好友不存在");
            return;
        }
        int rank = game.rank.getPointRaceAdapter().getRoleRank(game, inviteUid);
        if (rank < 0 || rank >= 100) {
            game.notice.message(cc.getRole(), "您的好友未满足参与条件");
            return;
        }
        game.pvp.teamPvp.inviteApply(cc.getRole(), inviteUid);
        game.notice.message(cc.getRole(), "已经发送邀请");
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTeamPvp.INVITE_FRIEND_REQ;
    }
}
